define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	/*var SqliteUtil = require("$UI/highde/modbusItems/lib/sqliteUtil");
	var DemoDB = require("$UI/highde/modbusItems/lib/demoDB");
	var netTcpHelp = require("$UI/highde/modbusItems/lib/netTcpHelp");
	var arrayBufferHelp = require("$UI/highde/modbusItems/lib/arrayBufferHelp");
	var g_ip = '127.0.0.1';
	var g_port = '502';
	var g_content = 'Hello';*/
	
	var Model = function(){
		this.callParent();
		/*this.demoDB = null;
		var self = this;
		netTcpHelp.ReceiveCallBack = function(info){
			self.comp('output1').set({value:JSON.stringify(arrayBufferHelp.ab2array(info.data))});
		};*/
	};
	Model.prototype.button1Click = function(event){
		/*var t_ip = this.comp('input1').val();
		var t_port = parseInt(this.comp('input2').val());
		var t_content = this.comp('input3').val();
		//this.comp('output1').set({value:s1+'--'+s2+'--'+s3})
		var db = this.demoDB.getDatabase();
		var sqlString = "UPDATE SETTINGSTRING SET fParamValue =? WHERE fParamName =?";
		if(t_ip != g_ip)
			SqliteUtil.executeSql(db, sqlString,[t_ip,'IP'],onSuccess,onError);
		if(t_port != g_port)
			SqliteUtil.executeSql(db, sqlString,[t_port,'PORT'],onSuccess,onError);
		if(t_content != g_content)
			SqliteUtil.executeSql(db, sqlString,[t_content,'SENDSTRING'],onSuccess,onError);
		function onSuccess(res){ }
		function onError(msg) { alert(false); }
		netTcpHelp.SendDataChrome(t_ip,t_port,t_content);*/
	};
	
	Model.prototype.modelLoad = function(event){
		/*if (!justep.Browser.isX5App) {
			alert("本案例只支持在手机APP中运行");
			return;
		}
		var self = this;
		// 设备准备好后，才能通过插件打开数据库
		document.addEventListener("deviceready", function() {
			// 这里在DemoDB.js中实现了一个单例对象，为了能在多个功能页中共用一个数据源，避免死锁
			self.demoDB = DemoDB.getInstance();
			// DemoDB.js中实现了自动判断并初始化数据库
			self.demoDB.initData(function() {
				SqliteUtil.executeSql(self.demoDB.getDatabase(), "SELECT * FROM SETTINGSTRING", [], onSuccess, onError);
				
				function onSuccess(res) {					
					for ( var i = 0, len = res.rows.length; i < len; i++) {
						var tempItem = res.rows.item(i);
						switch(tempItem.fParamName){
							case 'IP':
								self.comp('input1').set({value:tempItem.fParamValue});
								g_ip = tempItem.fParamValue;
							break;
							case 'PORT':
								self.comp('input2').set({value:tempItem.fParamValue});
								g_port = tempItem.fParamValue;
							break;
							case 'SENDSTRING':
								self.comp('input3').set({value:tempItem.fParamValue});
								g_content = tempItem.fParamValue;
							break;
							default:
							break;
						}
					}
				}
				function onError(msg) {
					alert(false, msg);
				}
			});
		});*/

	};

	return Model;
});